//NOTE: this .do file uses the following packages:
//spost13
//retrodesign
//collin


//SURVEY ANALYSES:

//TABLE 2: scores on combined death_penalty, gov_surveillance, increase_deports (unstandardized in appendix)
//MODEL I:
reg social_conservatism social_fear pid7 income education age gender white
listcoef, std help
//MODEL II:
reg social_conservatism total_fear pid7 income education age gender white 
listcoef, std help
//MODEL III:
reg social_conservatism fear_others fear_authority pid7 income education age gender white 
listcoef, std help


//FIGURE 1: individual measures (standardized coefficients used in Fig. 1, unstandardized coefficients in appendix table)
ologit increase_deports fear_others fear_authority pid7 income education age gender white
egen xothers=std(fear_others) if e(sample)
egen xauth=std(fear_authority) if e(sample)
ologit increase_deports xothers xauth pid7 income education age gender white
drop xothers xauth

ologit gov_surveillance fear_others  fear_authority pid7 income education age gender white 
egen xothers=std(fear_others) if e(sample)
egen xauth=std(fear_authority) if e(sample)
ologit gov_surveillance xothers xauth pid7 income education age gender white
drop xothers xauth

ologit death_penalty fear_others  fear_authority pid7 income education age gender white  //positive for others, negative for authority
egen xothers=std(fear_others) if e(sample)
egen xauth=std(fear_authority) if e(sample)
ologit death_penalty xothers xauth pid7 income education age gender white
drop xothers xauth





//LAB ANALYSES:

//Table 4
reg increase_deports threatSensitivity pid7 income education age gender white
reg gov_surveillance threatSensitivity pid7 income education age gender white
reg death_penalty threatSensitivity pid7 income education age gender white

//Figure 3
reg increase_deports i.auththreat threatSensitivity i.auththreat#c.threatSensitivity pid7 income education age gender white
margins auththreat, at(threatSensitivity=(-.25(.01).25) (mean) pid7 income education age gender white)
marginsplot, recast(line) recastci(rarea) ci1opt(color(gs10) color(%20)) ci2opt(color(gs10) color(%20)) xtitle("Threat Sensitivity (μS)" " ") graphregion(color(white)) xlabel(-.250(.05).25) yscale(range(1 6)) ylabel(1 `""Strongly" "Oppose""' 2 "Oppose" 3 `""Oppose" "Somewhat""' 4 `""Support" "Somewhat""' 5 "Support" 6 `" "Strongly" "Support" "') ylabel(,labsize(vsmall)) legend(bmargin(0 0 0 -3) order(3 "Fear Out-Groups" 4 "Fear Authority") rows(1) color(%100) size(small)) ytitle("Increase Deportations", size(small) height(6)) title("") xlabel(,labsize(small)) xtitle(,height(-3) size(small)) xscale(titlegap(*30)) plot1opts(lwidth(.5)) plot2opts(lwidth(.5) lpattern(shortdash))

//Figure 4
reg gov_surveillance i.auththreat threatSensitivity i.auththreat#c.threatSensitivity pid7 income education age gender white
margins auththreat, at(threatSensitivity=(-.250(.01).25) (mean) pid7 income education age gender white)
marginsplot, recast(line) recastci(rarea) ci1opt(color(gs10) color(%20)) ci2opt(color(gs10) color(%20)) xtitle("Threat Sensitivity (μS)" " ") graphregion(color(white)) xlabel(-.250(.05).25) yscale(range(1 6)) ylabel(1 `""Strongly" "Oppose""' 2 "Oppose" 3 `""Oppose" "Somewhat""' 4 `""Support" "Somewhat""' 5 "Support" 6 `" "Strongly" "Support" "') ylabel(,labsize(vsmall)) legend(bmargin(0 0 0 -3) order(3 "Fear Out-Groups" 4 "Fear Authority") rows(1) color(%100) size(small)) ytitle("Mass Surveillance", size(small) height(6)) title("") xlabel(,labsize(small)) xtitle(,height(-3) size(small)) xscale(titlegap(*30)) plot1opts(lwidth(.5)) plot2opts(lwidth(.5) lpattern(shortdash))

//Figure 5
reg death_penalty i.auththreat threatSensitivity i.auththreat#c.threatSensitivity pid7 income education age gender white //null results
margins auththreat, at(threatSensitivity=(-.250(.01).25) (mean) pid7 income education age gender white)
marginsplot, recast(line) recastci(rarea) ci1opt(color(gs10) color(%20)) ci2opt(color(gs10) color(%20)) legend(bmargin(0 0 0 -3) order(3 "Fear Out-Groups" 4 "Fear Authority") rows(1) color(%100) size(small)) xtitle("Threat Sensitivity (μS)" " ") graphregion(color(white)) xlabel(-.250(.05).25) yscale(range(1 6)) ylabel(1 `""Strongly" "Oppose""' 2 "Oppose" 3 `""Oppose" "Somewhat""' 4 `""Support" "Somewhat""' 5 "Support" 6 `" "Strongly" "Support" "') ylabel(,labsize(vsmall)) ytitle("Death Penalty", size(small) height(6)) title("") xlabel(,labsize(small)) xtitle(,height(-3) size(small)) xscale(titlegap(*30)) plot1opts(lwidth(.5)) plot2opts(lwidth(.5) lpattern(shortdash))




//APPENDIX ANALYSES:

//Correlations:
corr social_fear total_fear fear_others fear_authority

//Multicollinearity Analysis
collin fear_others fear_authority pid7 income education age gender white

//Mean phobic-anxiety scores, by group
sum social_fear total_fear fear_others fear_authority if age<25
sum social_fear total_fear fear_others fear_authority if age>=25 & age<40
sum social_fear total_fear fear_others fear_authority if age>=40 & age<65
sum social_fear total_fear fear_others fear_authority if age>=65

sum social_fear total_fear fear_others fear_authority if gender==0
sum social_fear total_fear fear_others fear_authority if gender==1

sum social_fear total_fear fear_others fear_authority if white==1
sum social_fear total_fear fear_others fear_authority if black==1
sum social_fear total_fear fear_others fear_authority if hispanic==1
sum social_fear total_fear fear_others fear_authority if asian==1

sum social_fear total_fear fear_others fear_authority if educ==2
sum social_fear total_fear fear_others fear_authority if educ==5
sum social_fear total_fear fear_others fear_authority if educ==6

sum social_fear total_fear fear_others fear_authority if pid7==-3
sum social_fear total_fear fear_others fear_authority if pid7==-2
sum social_fear total_fear fear_others fear_authority if pid7==-1
sum social_fear total_fear fear_others fear_authority if pid7==0
sum social_fear total_fear fear_others fear_authority if pid7==1
sum social_fear total_fear fear_others fear_authority if pid7==2
sum social_fear total_fear fear_others fear_authority if pid7==3

//TABLE 2 (unstandardized version)
reg social_conservatism social_fear pid7 income education age gender white
reg social_conservatism total_fear pid7 income education age gender white 
reg social_conservatism fear_others fear_authority pid7 income education age gender white 

//FIGURE 1 (unstandardized version)
ologit increase_deports fear_others fear_authority pid7 income education age gender white
ologit gov_surveillance fear_others  fear_authority pid7 income education age gender white 
ologit death_penalty fear_others  fear_authority pid7 income education age gender white

//FIGURE 4
reg increase_deports i.auththreat threatSensitivity i.auththreat#c.threatSensitivity pid7 income education age gender white
vif

//FIGURE 5
reg gov_surveillance threatSensitivity auththreat authSensitivity pid7 income education age gender white
vif

//FIGURE 6
reg death_penalty threatSensitivity auththreat authSensitivity pid7 income education age gender white
vif

//Power calculations for interaction effects
retrodesign -3.579903, se(1.532682) //deportations
retrodesign -3.807333, se(1.841724) //surveillance
retrodesign 0.5091529, se(1.849669) //death penalty